#ifndef xpack_test_extern_helper
#define xpack_test_extern_helper
#pragma push_macro("xuser")
#undef  xuser
#define xuser mixc::test_extern_helper::inc
#include"configure/switch.hpp"
#include"define/base_type.hpp"
#include"macro/private/log.hpp"
#include"lang/cxx/format.hpp"
#include"lang/cxx/index_of_last.hpp"
#include"lang/cxx.hpp"
#include"test/helper.hpp"
#pragma pop_macro("xuser")

namespace mixc::test_helper{
    inline uxx offset       = not_exist;

    mixc_test_context::mixc_test_context(asciis path, uxx line, asciis func_name, uxx error_limit){
        using namespace mixc::test_extern_helper::inc;

        *__mixc_test_context= this;
        helper::nlrd_counter::reset_counter();

        if (offset == not_exist){
            c08 token       = xmixc;
            offset          = c08{path}.index_of_last(token);
            offset         += token->length + 1; // maybe \\ or /
        }

        if (path[0] == '.'){
            this->path      = path + 2; // ignore ./
        }
        else{
            this->path      = path + offset;
        }

        this->line          = line;
        this->func_name     = func_name;
        this->error_limit   = error_limit;
    }

    mixc_test_context::~mixc_test_context(){
        using namespace mixc::test_extern_helper::inc;

        if (case_count == pass_count){
            log(log_type_t::for_test, path, line, func_name, "[PASS]", message_type_t::success);
        }
        else{
            log(log_type_t::for_hint, path, line, func_name, "case, pass, fail, pass_rate,", message_type_t::normal, 
                case_count, pass_count, case_count - pass_count, 1.0 * pass_count / case_count
            );
        }
    }
}

#endif
